'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.ensureAttr = undefined;

var _get = require('lodash/get');

var _get2 = _interopRequireDefault(_get);

var _set = require('lodash/set');

var _set2 = _interopRequireDefault(_set);

var _has = require('lodash/has');

var _has2 = _interopRequireDefault(_has);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ensureAttr = exports.ensureAttr = function ensureAttr(obj) {
    var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
    var defVal = arguments[2];

    if ((0, _has2.default)(obj, path)) {
        return (0, _get2.default)(obj, path);
    }
    (0, _set2.default)(obj, path, defVal);
    return defVal;
};
exports.default = ensureAttr;